<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON_JAYepep</title>
</head>
<body>
    <script type="text/javascript">
        var user = {
            name : "jayepep",
            age : 3,
            sex : "男"
        };
        // 将js对象转换成json字符串
        var str = JSON.stringify(user);
        console.log(str);
        // 将json字符串转换成js对象
        var user2 = JSON.parse(str);
        console.log(user2.name, user2.age, user2.sex);
    </script>
</body>
</html>